package com.dkm.biz.ou.repository.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import com.dkm.biz.ou.persistence.dao.UserAccountDao;
import org.springframework.stereotype.Repository;

import com.dkm.base.core.helper.SpringHelper;
import com.dkm.base.db.persistence.dao.IQueryDao;
import com.dkm.biz.repository.AbstractRepository;
import com.dkm.biz.ou.domain.UserAccount;
import com.dkm.biz.ou.repository.UserAccountRepository;
import com.dkm.biz.ou.persistence.dao.UserAccountQueryDao;
import com.dkm.biz.ou.persistence.entity.UserAccountPo;

/**
 * 对象功能:user_account Repository接口的实现类
 * 开发公司:dkm.com
 * 开发人员:ZHH
 * 创建时间:2017-07-31 20:14:54
 */
@Repository
public class UserAccountRepositoryImpl extends AbstractRepository<String, UserAccountPo,UserAccount> implements UserAccountRepository{
	  
	@Resource
	private  UserAccountQueryDao userAccountQueryDao;
	@Resource
	private UserAccountDao userAccountDao;

	public UserAccount newInstance() {
		UserAccountPo po = new UserAccountPo();
		UserAccount userAccount = SpringHelper.getBean(UserAccount.class);
		userAccount.setData(po);
		return userAccount;
	}

	public UserAccount newInstance(UserAccountPo po) {
		UserAccount userAccount = SpringHelper.getBean(UserAccount.class);
		userAccount.setData(po);
		return userAccount;
	} 
	
	@Override
	protected IQueryDao<String, UserAccountPo> getQueryDao() {
		return userAccountQueryDao;
	}

	@Override
	public void updateBalance(UserAccountPo po){
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("id", po.getId());
		params.put("balance", po.getBalance());
		userAccountDao.updateByKey("updateBalance", params);
	}
	
}
